package com.jbinfo.mgosql.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.jbinfo.mgosql.operation.simple.model.SimpleDTO;
import com.jbinfo.mgosql.operation.simple.service.ISimpleService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.siufung.boot.mybatis.intercetpor.Pagination;

@RestController
@RequestMapping("/simple")
@Api("simple相关的API")
public class SimpleController {
	
	@Autowired
	private ISimpleService simpleService;
	
	@ApiOperation("增加一个SimpleDTO")
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public void addSimpleDto(
			@ModelAttribute SimpleDTO simpleDto) {
		simpleService.insert(simpleDto);
    }
	
	@ApiOperation("获取所有的SimpleDTO")
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public List<SimpleDTO> getAll() {
	     return simpleService.findList();
	}
	
	@ApiOperation("SimpleDTO分页")
	@RequestMapping(value = "/getPage", method = RequestMethod.GET)
	public Pagination<SimpleDTO> getPage(@ModelAttribute SimpleDTO simpleDto) {
		Pagination<SimpleDTO> pagination=simpleService.getPage(simpleDto);
		return pagination;
	}
	
	
	
	
}
